package com.bdan.t382.service.imp;

import com.bdan.t382.dao.PetDao;

import com.bdan.t382.dao.imp.PetDaoOracleImpl;
import com.bdan.t382.entity.Pet;
import com.bdan.t382.service.PetService;


 import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;

@Service("petService")
public class PetServiceImpl implements PetService {
@Resource(type = PetDaoOracleImpl.class)
private PetDao petDao;
@Override
public boolean save(Pet pet) {
    int rows = petDao.insert(pet) ;
    delay(3000); // 模拟执行业务 3 秒，注意：这里把抛出异常代码删除
    return rows > 0;
     }
 @Override
 public boolean modify(Pet pet) {
     delay(2000);// 模拟执行业务 2 秒
     return false;
     }
 @Override
 public boolean del(Integer id) {
      delay(1000);// 模拟执行业务 1 秒
      return false;
      }
 // 模拟业务执行所需的时间
      private void delay(int time) {
      try {
       Thread.sleep(time);
       } catch (InterruptedException e) {
       e.printStackTrace();
       }
      }
 }
